package com.server.questionbank.snframe.mapper.QuestionBank;

import com.server.questionbank.snframe.domain.QuestionBank.Question;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;

@Mapper
public interface QuestionMapper {
    /**
     * 根据题id查询问题
     * @param exercisesId
     * @return
     */
    @Select("SELECT * FROM T_question WHERE exercises_id = #{exercisesId} ORDER BY display_order asc")
    public List<Question> getQuestionByExercisesId(@Param("exercisesId") Long exercisesId);

    @Select("SELECT question_type FROM T_question WHERE question_type  = #{questionType}")
    List<Question> searchByQuestionParams(@Param("questionType") String questionType);




    /**
     * 根据题目ID数组查询关联问题
     */
    @Select({
            "<script>",
            "SELECT * FROM T_question WHERE exercises_id IN",
            "<foreach item='id' collection='exerciseIds' open='(' separator=',' close=')'>",
            "   #{id}",
            "</foreach>",
            "ORDER BY display_order",
            "</script>"
    })
    List<Question> findByExerciseIds(@Param("exerciseIds") List<Long> exerciseIds);
























}
